<?php
/**
* @version		$Id:controller.php  1 2013-10-12Z  $
* @package		Cashbag
* @subpackage 	Controllers
* @copyright	Copyright (C) 2013, . All rights reserved.
* @license #
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

/**
 * Variant Controller
 *
 * @package    
 * @subpackage Controllers
 */
class CashbagController extends JControllerLegacy
{

	protected $_viewname = 'item';
	protected $_mainmodel = 'item';
	protected $_itemname = 'Item';    
	protected $_context = "com_cashbag";
	/**
	 * Constructor
	 */
		 
	public function __construct($config = array ()) {
		
		parent :: __construct($config);

		if(isset($config['viewname'])) $this->_viewname = $config['viewname'];
		if(isset($config['mainmodel'])) $this->_mainmodel = $config['mainmodel'];
		if(isset($config['itemname'])) $this->_itemname = $config['itemname']; 

		JRequest :: setVar('view', $this->_viewname);

	}

	public function display() {
		
		$document =& JFactory::getDocument();
                
                $vmuser = & JFactory::getUser();
                
                $layout     = JRequest::getWord('layout', '');
                
                if($vmuser->guest && $layout != 'proposition' && $layout != 'finish'){//seul ceux qui viennent pour accepter/refuser une proposition ont accès en tant que guest!
                    
                    echo '<div class="cadre0"><div class="cadre1"><div class="cadre2"<h3>Vous devez vous authentifier pour y accéder, clicquez '
                            . '<a class="jcetooltip jcepopup noicon" dir="ltr" type="text/html" href="index.php?option=com_users&amp;view=login&amp;tmpl=component" data-mediabox="width[600];height[360]">'
                            .'ici</a> </h3></div></div></div>';
                    
                }else{
                    $viewType	= $document->getType();
                    $view = & $this->getView($this->_viewname,$viewType);
                    $model = & $this->getModel($this->_mainmodel);

                    $view->setModel($model,true);		
                    $view->display();
                }
	}
	

}// class
  	

  
?>